<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <!--[if lt IE 9]>
    <script type="text/javascript" src="/backs/lib/html5shiv.js"></script>
    <script type="text/javascript" src="/backs/lib/respond.min.js"></script>
   <![endif]-->
    <link rel="stylesheet" type="text/css" href="/backs/static/h-ui/css/H-ui.min.css"/>
    <link rel="stylesheet" type="text/css" href="/backs/static/h-ui.admin/css/H-ui.admin.css"/>
    <link rel="stylesheet" type="text/css" href="/backs/lib/Hui-iconfont/1.0.8/iconfont.css"/>
    <link rel="stylesheet" type="text/css" href="/backs/static/h-ui.admin/skin/default/skin.css" id="skin"/>
    <link rel="stylesheet" type="text/css" href="/backs/static/h-ui.admin/css/style.css"/>
    <!--[if IE 6]>
    <script type="text/javascript" src="/backs/lib/DD_belatedPNG_0.0.8a-min.js"></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
    <title>订单列表</title>
</head>
<body>

<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 订单管理 <span
            class="c-gray en">&gt;</span> 订单列表 <a class="btn btn-success radius r"
                                                  style="line-height:1.6em;margin-top:3px"
                                                  href="javascript:location.replace(location.href);" title="刷新"><i
                class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">

    <div class="cl pd-5 bg-1 bk-gray mt-20"><span class="l">
            <a href="javascript:;" onclick="datadel()" class="btn btn-danger radius"><i
                        class="Hui-iconfont">&#xe6e2;</i> 批量删除</a>
          </span>
        <span class="r">共有：<strong><?= $count ?></strong> 条订单</span>
    </div>
    <div id="Delivery_stop" style=" display:none;padding: auto;">
        <div class="padding15">
            <div class="content_style">
                <label class="input-text"> 选择快递公司和快递号：</label>
                <div class="form-group">
                    <select class="input-text" id="form-field-select-1">
                        <option value="">--选择快递--</option>
                        <option value="1">天天快递</option>
                        <option value="2">圆通快递</option>
                        <option value="3">中通快递</option>
                        <option value="4">顺丰快递</option>
                        <option value="5">申通快递</option>
                        <option value="6">邮政EMS</option>
                        <option value="7">邮政小包</option>
                        <option value="8">韵达快递</option>
                    </select>
                </div>
                <div class="form-group">
                    <input type="text" id="form-field-1" placeholder="快递号" class="input-text" style="margin-left:0px;">
                </div>
            </div>
        </div>
    </div>
    <div class="mt-20">
        <table class="table table-border table-bordered table-bg table-hover table-sort table-responsive">
            <thead>
            <tr class="text-c">
                <th width="25"><input type="checkbox" name="" value=""></th>
                <th>订单编号</th>
                <th>商品名称</th>
                <th>添加人</th>
                <th>总价</th>
                <th>订单时间</th>
                <th>订单类型</th>
                <th>状态</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <?php foreach ($data as $k => $v) {
                $status = '';
                if ($v['order_status'] == '1') {
                    $status = '已发货';
                } elseif ($v['order_status'] == '2') {
                    $status = '待付款';
                } elseif ($v['order_status'] == '3') {
                    $status = '待发货';
                }
                ?>
                <tr class="text-c delTr<?= $v['order_id'] ?>">
                    <td><input type="checkbox" value="<?= $v['order_id'] ?>" class="ase"
                               cid="<?= $v['consignee_id'] ?>"></td>
                    <td><?= $v['order_number'] ?></td>
                    <td>
                        <?php foreach ($v['shop_name'] as $va) {?>
                            <?=$va['shop_name']."*".$va['num']?>&nbsp;&nbsp;&nbsp;
                        <?php } ?>
                    </td>
                    <td> <?= $v['submitter'] ?></td>
                    <td><?= $v['order_amount'] ?></td>
                    <td><?= $v['order_time'] ?></td>
                    <td><?= $v['order_type'] ?></td>
                    <td class="td-status"><span class="label label-success radius"><?= $status ?></span></td>
                    <td class="f-14 td-manage">
                        <?php if ($v['order_status'] == 3) { ?>
                            <a style="text-decoration:none" onClick="article_stop(this,<?= $v['order_id'] ?>)"
                               href="javascript:;" title="发货"><i class="Hui-iconfont">&#xe6de;</i></a>
                        <?php } ?>
                        <a style="text-decoration:none" class="ml-5"
                           onClick="article_edit('订单详情','<?= $v['order_id'] ?>')" href="javascript:;" title="详情"><i
                                    class="Hui-iconfont">&#xe6df;</i></a>
                        <a style="text-decoration:none" class="ml-5"
                           onClick="article_del(this,'<?= $v['order_id'] ?>','<?= $v['consignee_id'] ?>')"
                           href="javascript:;" title="删除"><i class="Hui-iconfont">&#xe6e2;</i></a>
                    </td>
                </tr>
            <?php } ?>
            </tbody>
        </table>
    </div>
</div>
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="/backs/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="/backs/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="/backs/static/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="/backs/static/h-ui.admin/js/H-ui.admin.js"></script>
<!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="/backs/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="/backs/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="/backs/lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript">
    $('.table-sort').dataTable({
        "aaSorting": [[1, "desc"]],//默认第几个排序
        "bStateSave": true,//状态保存
        "pading": false,
        "aoColumnDefs": [
            //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
            {"orderable": false, "aTargets": [0, 8]}// 不参与排序的列
        ]
    });

    /*资讯-编辑*/
    function article_edit(title, id) {
        var index = layer.open({
            type: 2,
            title: title,
            content: '/admin/orderdetails?id=' + id
        });
        layer.full(index);
    }

    /*资讯-删除*/
    function article_del(obj, id, cid) {

        layer.confirm('确认要删除吗？', function (index) {
            $.post('/admin/orderdel', {str: id, cid: cid}, function (res) {
                    if (res == 1) {
                        $(obj).parents("tr").remove();
                        layer.msg('已删除!', {icon: 1, time: 1000});
                    } else {
                        layer.msg('删除失败!', {icon: 1, time: 1000});
                    }

                },
            );
        });
    }

    /**
     *
     **/
    function datadel() {
        var str = '';
        var c_id = '';
        $('.ase').each(function () {
            var fsle = $(this).prop('checked');
            if (fsle) {
                var cid = $(this).attr('cid');
                var id = $(this).val();
                str += id + ",";
            }
        })
        if (str) {
            layer.confirm('是否删除！', function (index) {
                $.post('/admin/orderdel', {str: str}, function (res) {
                    if (res == 1) {
                        layer.alert('删除成功！')
                        $('.ase').each(function () {
                            var fsle = $(this).prop('checked');
                            if (fsle) {
                                var id = $(this).val()
                                $('.delTr'+id).remove();
                            }
                        });
                    } else {
                        layer.alert('删除失败！')
                    }
                });
            })
        } else {
            layer.alert('请选择您要删除的数据!');

        }
    }

    /*
    * 发货
    * */
    function article_stop(obj, id) {
        layer.open({
            type: 1,
            title: '发货',
            maxmin: true,
            shadeClose: false,
            area: ['500px', ''],
            content: $('#Delivery_stop'),
            btn: ['确定', '取消'],
            yes: function (index, layero) {
                var express_num = $('#form-field-1').val();
                var express_id = $('#form-field-select-1').val();
                if (express_num == "" || express_id == "") {
                    layer.alert('选项不能为空！', {
                        title: '提示框',
                        icon: 0,
                    })
                } else {
                    $.post('/admin/ordershipments', {
                        id: id,
                        express_num: express_num,
                        express_id: express_id
                    }, function (res) {
                        if (res == 1) {
                            layer.confirm('提交成功！', function (index) {
                                $(obj).parents("tr").find(".td-status").html('<span class="label label-success radius">已发货</span>');
                                $(obj).remove();
                                layer.msg('已发货!', {icon: 6, time: 1000});
                            });
                        } else {
                            layer.confirm('提交失败！')
                        }
                    });
                    layer.close(index);
                }

            }
        })
    };

    /*资讯-申请上线*/
    function article_shenqing(obj, id) {
        $(obj).parents("tr").find(".td-status").html('<span class="label label-default radius">待审核</span>');
        $(obj).parents("tr").find(".td-manage").html("");
        layer.msg('已提交申请，耐心等待审核!', {icon: 1, time: 2000});
    }

</script>
</body>
</html>